package com.demo.androidgame.finsternis;

import com.demo.androidgame.fx.DynamicGameObject;

public class Nis extends DynamicGameObject {
    public static final int BOB_STATE_JUMP = 0;
    public static final int BOB_STATE_FALL = 1;
    public static final int BOB_STATE_HIT = 2;
    
    public static final float BOB_JUMP_VELOCITY = 7.1f;    
    public static final float BOB_MOVE_VELOCITY = 9;
    public static final float BOB_WIDTH = 1;
    public static final float BOB_HEIGHT = 1;
    
    int state;
    float stateTime;    

    public Nis(float x, float y) {
        super(x, y, BOB_WIDTH, BOB_HEIGHT); 
        state = BOB_STATE_FALL;
        stateTime = 0;        
    }

    public void update(float deltaTime) {     
        velocity.add(World.gravity.x * deltaTime, World.gravity.y * deltaTime);
        position.add(-(velocity.x * deltaTime), velocity.y * deltaTime);
        bounds.lowerLeft.set(position).sub(bounds.width /2 ,bounds.height /2);
      
        if(position.x < 0)
            position.x = 0;
        if(position.x > World.WORLD_WIDTH)
            position.x = World.WORLD_WIDTH;
        
        stateTime += deltaTime;
    }
    public void hitPlatform() {
        velocity.y = BOB_JUMP_VELOCITY;
        state = BOB_STATE_FALL;
        stateTime = 0;
    }
}
